

/*
getnamne
setname
 */



class Person {
    private String name;
    private int age;



    public Person() {

    }
    public Person(String name,int age) {
        this.name = name;
        this.age = age;
    }


    public String getName() {       //提供get和set方法帮我来访问Person类中的Private修饰的成员变量
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }


    public void eat() {
        System.out.println(name+" 吃饭！");
    }
    public void show() {
        System.out.println(name + " " + age);
    }

}






public class Test {
    public static void main(String[] args) {
        Person person = new Person("zhangsan",10);
        person.show();
        person.setName("yangdike"); //重新给person类的name赋值
        person.setAge(20);
        System.out.println(person.getName());//打印getName的值
        person.show();

    }

}
